home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / chap6 / 6_8 / newd_c / array.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  1017 b   |  55 lines

  1.  
  2.  
  3. #ifndef ARRAY_H
  4. #define ARRAY_H
  5.  
  6. #include <stdlib.h>
  7.  
  8. typedef struct _array *Array;
  9.  
  10. struct _array
  11. {
  12.     void **data;
  13.     unsigned int size;
  14.     unsigned int used;
  15. };
  16.  
  17. /* Creates an Array, of the given size and returns it */
  18.  
  19.     Array array_alloc(unsigned int aSize);
  20.  
  21. /* Frees and array, not the items in it */
  22.  
  23.     void array_free(Array anArray);
  24.     
  25. /* Frees the items, not the array */
  26.  
  27.     void array_freeItems(Array anArray);
  28.  
  29. /* returns the current size of an Array */
  30.  
  31.     int array_count(Array anArray);
  32.     
  33. /* Sets the capacity of the array */
  34.  
  35.     void array_setCapacity(Array anArray,unsigned int aSize);
  36.  
  37. /* Adds an item to the end of the array */
  38.  
  39.     void array_addItem(Array anArray,void *anItem);
  40.  
  41. /* Inserts an item into the array */
  42.  
  43.     void array_addItemAt(Array anArray,void *anItem,unsigned int index);
  44.     
  45. /* Returns an item from the array */
  46.  
  47.     void * array_itemAt(Array anArray,unsigned int index);
  48.  
  49. /* Removes an item from the array, and returns it */
  50.  
  51.     void * array_removeItemAt(Array anArray,unsigned int index);
  52.  
  53. #endif
  54.  
  55.